{% macro gen_table(users) %}
    <table id="user-info-table" class="table table-bordered table-hover table-condensed table-striped">
        <thead>
            <tr>
                <th>用户ID</th>
                <th>手机号</th>
                <th>昵称</th>
                <th>省份</th>
                <th>大区</th>
                <th>绑定</th>
                <th>总付费</th>
                <th>总机会</th>
                <th>成单数</th>
                <th>货单价</th>
                <th>赠送单</th>
                <th>养成指数</th>
                <th>注册时间</th>
                <th>状态</th>
                <th>标签</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {% for user in users %}
            <tr>
                <td>{{ user.id }}</td>
                <td>{{ user.mobile | encrypt }}</td>
                <td>{{ user.nickname }}</td>
                <td>{{ user.prov[:2] }}</td>
                <td>{{ user.war_zone.name }}</td>
                {% if user.wx_openid != '' %}
                    <td>已绑定</td>
                {% else %}
                    <td>未绑定</td>
                {% endif %}
                <td>{{ user.total_pay_amount }}</td>
                <td>{{ user.total_opportunity_count }}</td>
                <td>{{ user.close_deal_count }}</td>
                <td>{{ user.user_demand_unit_price }}</td>
                <td>{{ user.total_gift_partic_count }}</td>
                <td>{{ user.training_index }}</td>
                <td>{{ user.created_datetime.strftime('%F') }}</td>
                <td>{{ user.training_status_display }}</td>
                <td>
                    {% if user.tag_phone_contact %}
                        <span class="label label-info">已联系</span>
                    {% endif %}
                    {% if user.tag_add_wechat %}
                        <span class="label label-primary">已加微信</span>
                    {% endif %}
                </td>
                <td>
                    {% if user.training_status == 1 %}
                        <a class="btn btn-warning btn-xs"
                           href="{{ url_for('op_bp.toggle_user_training_status', user_id=user.id) }}"
                           onclick="return confirm('请确认要暂停养成?')"
                        >暂停</a>
                    {% elif user.training_status == 2 %}
                        <a class="btn btn-success btn-xs"
                           href="{{ url_for('op_bp.toggle_user_training_status', user_id=user.id) }}"
                           onclick="return confirm('请确认要恢复养成?')"
                        >养成</a>
                    {% endif %}
                    <a href="javascript:void(0);" class="btn btn-danger btn-xs user_add_tag"
                       data-user-id="{{ user.id }}"
                       data-user-nickname="{{ user.nickname }}"
                       data-user-mobile="{{ user.mobile }}"
                       data-tag_phone_contact="{{ user.tag_phone_contact }}"
                       data-tag_add_wechat="{{ user.tag_add_wechat }}"
                    >打标签</a>
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
{% endmacro %}
